import 'package:fate_blind_box/chat_pages/friend/apply_add_friend/logic.dart';
import 'package:fate_blind_box/chat_view/ahu_text.dart';
import 'package:fate_blind_box/config/app_style.dart';
import 'package:fate_blind_box/routes/page_route_names.dart';
import 'package:fate_blind_box/widget/meet_appbar.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import 'logic.dart';

class VerifyFriendApplyPage extends GetView<VerifyFriendApplyLogic> {
  const VerifyFriendApplyPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return  Scaffold(
      appBar: const MeetAppBar(
        title: '通过朋友验证',
      ),
      backgroundColor: Colors.white,
      body: SingleChildScrollView(
        padding: EdgeInsets.symmetric(horizontal: 14.w),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            SizedBox(height: 10.w),
            AhuText(text: '设置备注',
              color: '#777777'.stringToColor,
              fontWeight: FontWeight.w400,
              fontSize: 16,),
            SizedBox(height: 10.w),
            TextField(
                controller: controller.state.explainEditingController,
                textAlign: TextAlign.left,
                style: TextStyle(
                    color: const Color(0xff333333), fontSize: 16.sp),
                autofocus: false,
                //光标颜色
                cursorColor: "#614AC0".stringToColor,
                minLines: 1,
                maxLines: 5,
                inputFormatters: <TextInputFormatter>[
                  LengthLimitingTextInputFormatter(100),
                  // FilteringTextInputFormatter.allow(
                  //     Config.defaultReg),
                  //限制长度
                ],
                textAlignVertical: TextAlignVertical.center,
                decoration: InputDecoration(
                  labelStyle: TextStyle(
                      color: const Color(0xff999999),
                      fontSize: 14.sp),
                  hintText: '请输入备注',
                  hintStyle: TextStyle(
                      color: const Color(0xffAAAAAA),
                      fontSize: 14.sp),
                  contentPadding:
                  EdgeInsets.symmetric(horizontal: 14.w, vertical: 14.w),
                  focusedBorder: OutlineInputBorder(
                    borderSide:
                    const BorderSide(color: Colors.transparent),
                    borderRadius:
                    BorderRadius.circular(5.w), // 设置圆角大小
                  ),
                  enabledBorder: OutlineInputBorder(
                    borderSide:
                    const BorderSide(color: Colors.transparent),
                    borderRadius:
                    BorderRadius.circular(5.w), // 设置圆角大小
                  ),
                  filled: true,
                  fillColor: '#F6F6F6'.stringToColor,
                  isCollapsed: false,
                  isDense: true,
                )),
            SizedBox(height: 20.w),
            AhuText(text: '设置朋友权限',
              color: '#777777'.stringToColor,
              fontWeight: FontWeight.w400,
              fontSize: 16,),
            SizedBox(height: 10.w),
            _limitsContent(),
            SizedBox(height: 20.w),
            AhuText(text: '朋友圈和状态',
              color: '#777777'.stringToColor,
              fontWeight: FontWeight.w400,
              fontSize: 16,),
            SizedBox(height: 20.w),
            _friendStatus(),
            SizedBox(height: 44.w),
            _sendContent(),
            SizedBox(height: 120.w),
          ],
        ),
      ),
    );
  }

  /// 设置朋友权限
  Widget _limitsContent() {
    return GetX<VerifyFriendApplyLogic>(
      init: VerifyFriendApplyLogic(),
      initState: (_) {},
      builder: (logic) {
        return Container(
          width: double.infinity,
          padding: EdgeInsets.symmetric(horizontal: 14.w),
          height: 100.w,
          decoration: BoxDecoration(
            color: '#F6F6F6'.stringToColor,
            borderRadius: BorderRadius.circular(5.w),
          ),
          child: Column(
            children: [
              SizedBox(height: 14.w),
              InkWell(
                onTap: ()=> logic.state.explain.value = false,
                child: Row(children: [
                  Expanded(child: AhuText(
                    text: '聊天、朋友圈', color: '#3A3A3A'.stringToColor,)),
                  logic.state.explain.value==false?Image.asset('images/select.png', width: 16.w, height: 16.w,):const SizedBox()
                ],),
              ),
              SizedBox(height: 14.w),
              Divider(color: '#D8D8D8'.stringToColor, height: 1.w,),
              SizedBox(height: 14.w),
              InkWell(
                onTap: ()=> logic.state.explain.value = true,
                child: Row(children: [
                  Expanded(child: AhuText(text: '聊天、仅聊天', color: '#3A3A3A'.stringToColor,)),
                  logic.state.explain.value==true?Image.asset('images/select.png', width: 16.w, height: 16.w,):const SizedBox()
                ],),
              ),
            ],
          ),
        );
      },
    );
  }

  /// 朋友状态
  Widget _friendStatus() {
    return Container(
      width: double.infinity,
      padding: EdgeInsets.symmetric(horizontal: 14.w),
      height: 140.w,
      decoration: BoxDecoration(
        color: '#F6F6F6'.stringToColor,
        borderRadius: BorderRadius.circular(5.w),
      ),
      child: Column(
        children: [
          SizedBox(height: 14.w),
          Row(children: [
            Expanded(child: AhuText(
              text: '不让他(她)看', color: '#3A3A3A'.stringToColor,)),
            GetX<ApplyAddFriendLogic>(
              init: ApplyAddFriendLogic(),
              initState: (_) {},
              builder: (logic) {
                return CupertinoSwitch(
                  value: logic.state.otherToMe.value,
                  onChanged: (value) {
                    logic.state.otherToMe.value = !logic.state.otherToMe.value;
                  },
                  activeColor: '#614AC0'.stringToColor,
                );
              },
            ),
          ],),
          SizedBox(height: 14.w),
          Divider(color: '#D8D8D8'.stringToColor, height: 1.w,),
          SizedBox(height: 14.w),
          Row(children: [
            Expanded(child: AhuText(
              text: '不看他(她)', color: '#3A3A3A'.stringToColor,)),
            GetX<ApplyAddFriendLogic>(
              init: ApplyAddFriendLogic(),
              initState: (_) {},
              builder: (logic) {
                return CupertinoSwitch(
                  value: logic.state.meToOther.value,
                  onChanged: (value) {
                    logic.state.meToOther.value = !logic.state.meToOther.value;
                  },
                  activeColor: '#614AC0'.stringToColor,
                );
              },
            ),
          ],),
        ],
      ),
    );
  }

  /// 发送按钮
  Widget _sendContent() {
    return InkWell(
      onTap: ()=> controller.completeAction(),
      child: Container(
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(44.w),
          color: '#614AC0'.stringToColor,
          boxShadow: [
            BoxShadow(
              color: '614AC0'.stringToColor,
              offset: const Offset(2, 2),
              blurRadius: 4,
            ),
          ],
        ),
        height: 44.w,
        child: const Center(child: AhuText(text: '完成',
          color: Colors.white,
          fontSize: 18,
          fontWeight: FontWeight.bold,)),
      ),
    );
  }
}
